Jump to content

Module:If any equal/sandbox

From Wikipedia, the free encyclopedia
require('strict')
local p = {}

p.main = function(frame)
	local match = false
	for pos, value in pairs(frame.args) do
		if type(pos)=='number' and value:lower()==frame.args.value:lower() then
			match = true
			break
		end
	end
	return match and 'yes' or 'no'
end

p.ifAnyEqual = function(frame)
	local parent = frame:getParent()
	if not parent.args then
		return nil
	end
	local match = false
	for pos, name in pairs(frame.args) do
		if type(pos)=='number' and parent.args[name] and parent.args[name]:lower()==frame.args.value:lower() then
			match = name
			break
		end
	end
	if match then
		local suffix = frame.args.suffix
		if suffix then
			return parent.args[match..suffix]
		else
			return match
		end
	end
end

return p